﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using ArtOfTest.WebAii.Controls.HtmlControls;

namespace SM2Utilities
{
    public class CommonLoader
    {
        public static void load(string strASPXpage)
        {
            string strCurrentURL = Utilities.GlobalObject.MANAGER.ActiveBrowser.Url;
            if (!strCurrentURL.Contains(strASPXpage) || strASPXpage.Equals("home.aspx"))
            {
                Utilities.GlobalObject.MANAGER.ActiveBrowser.NavigateTo(Utilities.GlobalRunning.SERVER_URL + strASPXpage);
                Utilities.GlobalObject.MANAGER.ActiveBrowser.WaitUntilReady();
                System.Threading.Thread.Sleep(Utilities.GlobalConfig.INT_WAIT_TIMEOUT_MILISECOND);
                Utilities.GlobalObject.LOGGER.log("Loaded [" + strASPXpage + "]");
            }
        }

        public static Boolean hasPaging()
        {
            try
            {
                Utilities.GlobalObject.MANAGER.ActiveBrowser.RefreshDomTree();

                if (Utilities.GlobalObject.MANAGER.ActiveBrowser.ContainsText("Next >"))
                {
                    return true;
                }
                else
                {
                    return false;
                }
            }
            catch
            {
                return false;
            }
        }
    }
}
